<template>
  <div>
    <input type="text" v-model.trim="val" @keyup.enter="search" />
    <ul>
      <li v-for="item in list" :key="item.id" @click="toPlay(item.id)">
        {{ item.name }}
      </li>
    </ul>
  </div>
</template>
<script>
// axios  下载  导入  使用
import axios from 'axios'
export default {
  data () {
    return {
      val: '',
      list: []
    }
  },
  methods: {
    async search () {
      const res = await axios({
        url: 'http://119.91.150.211:9000/search?keywords=' + this.val
      })
      this.list = res.data.result.songs
      console.log(res)
    },
    toPlay (id) {
      this.$router.push('/play?id=' + id)
    }
  },
  mounted () {
    // 改网站标题123
    // document.querySelector('title').innerText = '123'
    document.title = this.$route.meta.title
  }
}
</script>
<style></style>
